Repository navigation
sdp-types: read an SRTP suite by its whole name - #81
Merged
Merged
Conversation
The suite of an a=crypto attribute used to be matched by trying each known name as a prefix. A suite whose name starts with a known one, such as AEAD_AES_256_GCM_8, matched AEAD_AES_256_GCM and left "_8" behind. The attribute then failed to parse, and with it the whole session description. The branch for unknown suites never ran for such a name. Now the suite parser reads the whole name first and then compares it with the known names. AEAD_AES_256_GCM_8 parses as SrtpSuite::Ext, and the parser reads the rest of the description. This change replaces the alt over the known names in SrtpSuite::parse with one take_while1 followed by a match on the name. It adds three tests: a known suite, a suite whose name starts with a known one, and a complete crypto attribute with such a suite. The change edits only the sdp-types crate, and the SrtpSuite type is unchanged. A SIP trunk offered AEAD_AES_256_GCM_8 in its second crypto attribute, after a suite the library knows. A SIP endpoint built on ezk could not read that offer, so the call failed, although the endpoint supports the suite offered first. Offers that list suites unknown to the library now parse. An application can then pick a suite it supports from the offer. Test: cargo test -p ezk-sdp-types --all-features (80 passed) Test: the two new tests of the longer suite failed on the old parser Test: cargo clippy -p ezk-sdp-types --all-features --all-targets Test: cargo fmt -p ezk-sdp-types --check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SrtpSuite::parsecompares the known suite names one by one as prefixes, so a suite whose name starts with a known one fails to parse. Fora=crypto:2 AEAD_AES_256_GCM_8 inline:…, the nameAEAD_AES_256_GCMmatches and_8is left in front of the key. The crypto attribute then fails, and with it the whole session description. TheExtbranch for unknown suites never runs for such a name.A SIP trunk offered
AEAD_AES_256_GCM_8in its second crypto attribute, after a suite the library knows. An endpoint built on ezk could not read that INVITE, so the call failed.With this change the parser reads the whole name with
take_while1and then compares it with the known names.AEAD_AES_256_GCM_8parses asSrtpSuite::Ext. TheSrtpSuitetype is unchanged.cargo test -p ezk-sdp-types --all-featurespassed with 80 tests. Three are new: a known suite, a suite whose name starts with a known one, and a complete crypto attribute with such a suite.cargo clippy -p ezk-sdp-types --all-features --all-targetsandcargo fmt -p ezk-sdp-types --checkpassed.